package com.yjzx.util.common.util.BeanUtils;

import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author guozhi
 * @date 2025/1/9
 * @description LambdaUtils
 */
public class LambdaUtils {

    public static <T, R> R getFieldValue(T t, LambdaFunction<T, R> function) {
        return function.apply(t);
    }

    public static <R> R getFieldValue(LambdaSupper<R> supper) {
        return supper.get();
    }

    public static <T, V> void setFieldValue(LambdaConsumer<T, V> consumer, V value) {
        consumer.accept(value);
    }

    public static <T, V> void setFieldValue(T t, LambdaBiConsumer<T, V> consumer, V value) {
        consumer.accept(t, value);
    }

    public static void main(String[] args) throws ClassNotFoundException {
        class A{
            private String name;

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }
        }
        A a = new A();
        LambdaBiConsumer<A,String > lambdaFunction = A::setName;
        Class<?> lambda = lambdaFunction.getClassFromLambda();
        Method methodFromLambda = lambdaFunction.getMethodFromLambda();
        System.out.println();
    }

}
